home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
009
/
drverr.arc
/
DRVERR.PAS
Wrap
Pascal/Delphi Source File
|
1985-07-30
|
3KB
|
84 lines
{ Program to solve drive errors on IBM PC
Code by Marshall Brain.
The short program contained in this file demonstrates the use
of a procedure that will detect disk errors on the
IBM PC when the drive door is left open. It eliminates the
annoying "abort, retry, ignore?" message generated by DOS for
disk door errors. For example, when using the techniques shown here,
you will get an I/O error of 01 if you attempt to reset a file with
the drive door open, and an F0 if you try to rewrite a file with the
door open. You read these values out of the IOresult variable just
as you normally would, using $I- and $I+.
To use the technique shown here in your own programs, you
will need to do two things. First, you must copy BOTH the "setup"
procedure and the "int24" procedure into your program. Then you
must call "setup" before the int24 procedure will be effective.
"Setup" redirects DOS to the int24 procedure to handle errors. You
must also insure that "int24" is never swapped out in an overlay,
or the program will blow up. Please note that "setup" uses the "y"
variable to pick up the code segment location. You can use this
technique, or any other that you prefer. I just know that this
one works.
To run the example program given here, create a file called
"door.chk" on drive A: and run the program. It will work fine, and
reset the file with no problem. Then try leaving the drive door
open. After about 5 seconds, you will get the message that the door
is open, or that the file doesn't exist.
This technique isn't perfect - on file reading, you
only know whether the file is there OR that the door is open.
You never know which it is. On file writing you know that the door
is open, OR that the disk is full, but never which one. Also Note
that the DOS printer error gets tossed back to you by this
routine, so keep that in mind.
For me, this program is not perfect, but better than nothing. I
hope it is helpful. -MB}
program int24tst;
const
y : integer = 0;
var
fileptr:text;
procedure int24;
{To understand this routine, you will need to read}
{the description on Interrupt 24 in the DOS manual}
begin
inline
($58/ {POP AX Discard first 3 words on stack}
$58/ {POP AX }
$58/ {POP AX }
$58/ {POP AX Pop all registers}
$5b/ {POP BX }
$59/ {POP CX }
$5a/ {POP DX }
$5e/ {POP SI }
$5f/ {POP DI }
$5d/ {POP BP }
$1f/ {POP DS }
$07/ {POP ES }
$cf); {IRET Return to next instruction}
end;
procedure setup;
{Change interrupt vector 24 to point to the int24 procedure}
var result : record ax,bx,cx,dx,bp,si,di,ds,es,flags:integer; end;
begin
result.ds:=seg(y); {typed constants are stored in code seg}
result.dx:=ofs(int24)+7;
result.ax:=$2524;
intr($21,result);
end;
begin
setup;
assign(fileptr,'a:door.chk');
{$I-}
reset(fileptr);
{$I+}
if IOresult<>0 then
writeln('Either the drive door is open, or DOOR.CHK does not exist');
close(fileptr);
end.